# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=can
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=4.5.0
pkgrel=1
pkgdesc="Provides controller area network (CAN) support for Python developers (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/hardbyte/python-can"
msys2_documentation_url='https://python-can.readthedocs.io/'
msys2_references=(
  'archlinux: python-can'
  'purl: pkg:pypi/python-can'
)
license=('spdx:LGPL-3.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-packaging"
         "${MINGW_PACKAGE_PREFIX}-python-pywin32"
         "${MINGW_PACKAGE_PREFIX}-python-typing_extensions"
         "${MINGW_PACKAGE_PREFIX}-python-wrapt")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-mock"
              "${MINGW_PACKAGE_PREFIX}-python-nose"
              "${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-timeout"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-cov"
              "${MINGW_PACKAGE_PREFIX}-python-codecov"
              "${MINGW_PACKAGE_PREFIX}-python-future"
              "${MINGW_PACKAGE_PREFIX}-python-six")
options=('!strip')
source=("https://pypi.org/packages/source/p/python_${_realname}/python_${_realname}-${pkgver}.tar.gz")
sha256sums=('d3684cebe5b028a148c1742b3a45cec4fcaf83a7f7c52d0680b2eaeaf52f8eb7')

build() {
  cp -r "python_${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
